<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout"
      xmlns:th="http://www.thymeleaf.org"
      layout:decorator="backstage/layout">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=8" />
    <title th:text="${preliminaryContest.type==1?'预赛赛程':'淘汰赛赛程'}">预赛赛程</title>
</head>

<body>
<div id="content" layout:fragment="content">
<script type="text/javascript" src="../../../admin/js/bootstrap-paginator.js"></script>
<script type="text/javascript" src="../../../admin/ace/js/fuelux/fuelux.spinner.min.js"></script>
<script type="text/javascript" src="../../../admin/ace/js/ace-elements.min.js"></script>
<script type="text/javascript" src="../../../admin/js/preliminaryContest.js"></script>
    <div class="box-content">
        <div class="row-fluid sortable">
            <div class="box span12">
                <h3 class="row-fluid header smaller lighter blue">
                   <span class="label label-large label-pink arrowed-right" id="title-span" th:text="${preliminaryContest.type==1?'预赛赛程':'淘汰赛赛程'}"></span>
                </h3>
                
                <h3 class="row-fluid header smaller lighter blue">
                    <a class="btn btn-small btn-success btn-competition-team"
                       data-toggle="modal">参赛球队</a>
                    <a class="btn btn-small btn-success btn-preliminary-contest"
                       data-toggle="modal">预赛赛程</a>
                    <a class="btn btn-small btn-success btn-eliminate-contest"
                       data-toggle="modal">淘汰赛赛程</a>
                </h3>
                
                <h3 class="row-fluid header smaller lighter blue" th:if="${preliminaryContest.type==1}" style="border:none;">
                    <a class="btn btn-small btn-success import-btn"
                       data-toggle="modal">导入赛程</a>
                    <a class="btn btn-small btn-success export-btn"
                       data-toggle="modal">生成赛程导入表</a>
                </h3>
                
                <h3 class="row-fluid header smaller lighter blue" th:if="${preliminaryContest.type==2}" style="border:none;">
                    <a class="btn btn-small btn-success upload-btn"
                       data-toggle="modal">上传淘汰赛程图</a>
                    <a class="btn btn-small btn-success delete-btn"
                       data-toggle="modal">删除淘汰赛程图</a>
                </h3>
                
                <div id="preliminary-contest-list" class="row-fluid sortable ui-sortable">
               		<input type="hidden" id="seasonId" th:value="${preliminaryContest.seasonId}"/>
               		<input type="hidden" id="type" th:value="${preliminaryContest.type}"/>
                	<table class="table table-striped table-bordered table-hover competition-team-table contest-list">
                		<thead>
	                		<tr>
	                			<td style="width: 80px; text-align: center;">日期</td>
	                			<td style="width: 80px; text-align: center;">时间</td>
	                			<td style="width: 80px; text-align: center;">对阵队伍1</td>
	                			<td style="width: 80px; text-align: center;">对阵队伍2</td>
	                			<td style="width: 80px; text-align: center;">校区</td>
	                			<td style="width: 80px; text-align: center;">场地</td>
	                			<td style="width: 80px; text-align: center;">操作</td>
	                		</tr>
                		</thead>
                		<tbody>
	                		<tr th:if="${not #lists.isEmpty(preliminaryContestList)}" th:each="preliminaryContest:${preliminaryContestList}">
	                			<td name='date' style="width: 80px; text-align: center;">
	                				<span name='date-span' th:text="${preliminaryContest.date}"></span>
	                				<input type="hidden" readonly='readonly' name='date-input' class='Wdate span9' th:value="${preliminaryContest.date}" onFocus='new WdatePicker()'/>
	                			</td>
	                			<td name='time' style="width: 80px; text-align: center;">
	                				<span name='time-span' th:text="${preliminaryContest.time}"></span>
	                				<input type="hidden" name='time-input' style='width: 80px;' th:value="${preliminaryContest.time}"/>
	                			</td>
	                			<td name='teamName' style="width: 80px; text-align: center;">
	                				<span name='teamName-span' th:text="${preliminaryContest.teamName}"></span>
	                				<input type="hidden" name='teamName-input' style='width: 80px;' th:value="${preliminaryContest.teamId}"/>
	                				<a class='show-btn btn btn-info btn-small' name='teamName-a' style="display: none;">对阵球队1</a>
	                			</td>
	                			<td name='teamTwoName' style="width: 80px; text-align: center;">
	                				<span name='teamTwoName-span' th:text="${preliminaryContest.teamTwoName}"></span>
	                				<input type="hidden" name='teamTwoName-input' style='width: 80px;' th:value="${preliminaryContest.teamIdTwo}"/>
	                				<a class='show-btn btn btn-info btn-small' name='teamTwoName-a' style="display: none;">对阵球队2</a>
	                			</td>
	                			<td name='schoolName' style="width: 80px; text-align: center;">
	                				<span name='schoolName-span' th:text="${preliminaryContest.schoolName}"></span>
	                				<!-- <input type="hidden" name='schoolName-input' th:value="${preliminaryContest.schoolId}"/> -->
	                				<select name="school-select" style="display: none; width: 130px;">
				                		<option th:each="school:${schoolList}" th:selected="${preliminaryContest.schoolId == school.id}" th:value="${school.id}" th:text="${school.name}"></option>
				                	</select>
	                			</td>
	                			<td name='site' style="width: 80px; text-align: center;">
	                				<span name='site-span' th:text="${preliminaryContest.site}"></span>
	                				<input type="hidden" name='site-input' style='width: 80px;' th:value="${preliminaryContest.site}"/>
	                			</td>
	                			<td style="width: 80px; text-align: center;">
	                				<input type="hidden" name="id" th:value="${preliminaryContest.id}"/>
	                				<input type="button" class="btn btn-info btn-inverse update-btn" onclick="updateTeam(this)" value="修改"/>
	                				<input type="button" class="btn btn-info btn-inverse insert-btn" style="display: none;" onclick="insertTeam(this)" value="保存"/>
	                				<input type="button" class="btn btn-info btn-inverse cancel-btn" style="display: none;" onclick="cancelTeam(this)" value="取消" />
	                			</td>
	                		</tr>
                		</tbody>
                	</table>
                	<a class="show-btn btn btn-info btn-small add-contest-but">
               			添加赛程
                    </a>
                </div>
                
                <div class="widget-main" th:if="${eliminateImg != null}">
                    <img height="260" src="" id="eliminateImg" th:if="${eliminateImg != ''}" th:src="${eliminateImg}" style="margin:10px 0px;"/>
                </div>
                
                <div class="row-fluid sortable ui-sortable" th:if="${preliminaryContest.type == 1}" id="team-div" style="display: none;">
                    <div class="xpclass box span3" th:if="${not #lists.isEmpty(competitionGroupList)}" th:each="group,var:${competitionGroupList}">
                        <div class="widget-header">
                            <h2>
                                <span th:id="${group.id}" th:text="${group.name}"></span>
                            </h2>
                        </div>
                        <div class="widget-body">
                            <div class="widget-main" th:id="${group.id}">
                                <!-- <ul class="team-list" style="width: 260px;">
                                    <li class="rest-list clearfix" th:if="${group.competitionTeamList != null}" th:each="team:${group.competitionTeamList}">
                                       	<strong>序号:</strong>
                                       	<span th:text="${team.number}"></span>
                                           <br/>
                                       	<strong>球队名称:</strong>
                                       	<span tag="dateTimes" th:text="${team.teamName}"></span>
                                    </li>
                                 </ul> -->
                                 <table class="table table-striped table-bordered table-hover competition-team-table team-list" style="width: 260px;">
	                               		<tr th:if="${group.competitionTeam != null}">
	                               			<td th:text="${group.competitionTeam.number}"></td>
	                               			<td th:text="${group.competitionTeam.teamName}" name="teamName" th:id="${group.competitionTeam.teamId}"></td>
	                               		</tr>
	                               		<tr th:if="${group.competitionTeam == null}">
	                               			<td>1</td>
	                               			<td></td>
	                               		</tr>
	                               		
	                               		<tr th:if="${group.competitionTeam2 != null}">
	                               			<td th:text="${group.competitionTeam2.number}"></td>
	                               			<td th:text="${group.competitionTeam2.teamName}" name="teamName" th:id="${group.competitionTeam2.teamId}"></td>
	                               		</tr>
	                               		<tr th:if="${group.competitionTeam2 == null}">
	                               			<td>2</td>
	                               			<td></td>
	                               		</tr>
	                               		
	                               		<tr th:if="${group.competitionTeam3 != null}">
	                               			<td th:text="${group.competitionTeam3.number}"></td>
	                               			<td th:text="${group.competitionTeam3.teamName}" name="teamName" th:id="${group.competitionTeam3.teamId}"></td>
	                               		</tr>
	                               		<tr th:if="${group.competitionTeam3 == null}">
	                               			<td>3</td>
	                               			<td></td>
	                               		</tr>
	                               		
	                               		<tr th:if="${group.competitionTeam4 != null}">
	                               			<td th:text="${group.competitionTeam4.number}"></td>
	                               			<td th:text="${group.competitionTeam4.teamName}" name="teamName" th:id="${group.competitionTeam4.teamId}"></td>
	                               		</tr>
	                               		<tr th:if="${group.competitionTeam4 == null}">
	                               			<td>4</td>
	                               			<td></td>
	                               		</tr>
	                               </table>
							</div>
                                    <!-- </li>
                                 </ul> -->
                            </div>
                        </div>
                    </div>
            </div><!--/span-->
        </div><!--/row-->
    </div>
    
    <div class="container-fluid" th:if="${preliminaryContest.type == 2}">
        <div id="team-model" class="modal hide fade in" style="display: none;">
            <div class="modal-header">
                <button class="close" data-dismiss="modal" type="button">×</button>
            </div>
            <table class="table table-striped table-bordered table-hover competition-team-table team-model-list">
           		<tbody>
            		<tr th:if="${not #lists.isEmpty(competitionTeamList)}" th:each="team:${competitionTeamList}">
            			<td name='groupId' style="width: 80px; text-align: center;" th:text="${team.groupId}"></td>
            			<td name='team' style="width: 80px; text-align: center;" th:text="${team.teamName}" th:id="${team.teamId}"></td>
            		</tr>
           		</tbody>
           	</table>
        </div>
    </div>
    
    <div class="container-fluid">
        <div id="import-model" class="modal hide fade in" style="display: none;">
            <div class="modal-header">
                <button class="close" data-dismiss="modal" type="button">×</button>
                <h3>导入预赛赛程</h3>
            </div>
            <form class="form-horizontal" style="margin: 0" enctype="multipart/form-data" action="/preliminaryContest/importContest.json" method="post" id="importContestForm">
                <input type="hidden" name="seasonId" th:value="${preliminaryContest.seasonId}"/>
                <fieldset>
                    <div class="modal-body">                        
	                    <div class="control-group">
	                        <label class="control-label">文件：</label>
	                        <div class="controls">
	                            <div class="widget-main">
		                        	<input type="file" id="id-input-file" name="file"/>
			                    </div>
	                        </div>
	                      </div>
                    </div>
                    <div class="modal-footer">
                        <div style="display: none"><input type="reset" id="addResult"/></div>
                        <input type="submit" class="btn btn-primary" value="导入"/>
                        <a href="#" class="btn btn-small" data-dismiss="modal">取消</a>
                    </div>
                </fieldset>
            </form>
        </div>
    </div>
    
    <div class="container-fluid">
        <div id="upload-model" class="modal hide fade in" style="display: none;">
            <div class="modal-header">
                <button class="close" data-dismiss="modal" type="button">×</button>
                <h3>上传淘汰赛程图片</h3>
            </div>
            <form class="form-horizontal" style="margin: 0" enctype="multipart/form-data" action="/preliminaryContest/uploadEliminateImg.json" method="post" id="uploadImgForm">
                <input type="hidden" name="seasonId" th:value="${preliminaryContest.seasonId}"/>
                <fieldset>
                    <div class="modal-body">                        
	                    <div class="control-group">
	                        <label class="control-label">文件：</label>
	                        <div class="controls">
	                            <div class="widget-main">
		                        	<input type="file" id="id-input-file2" name="file"/>
			                    </div>
	                        </div>
	                      </div>
                    </div>
                    <div class="modal-footer">
                        <div style="display: none"><input type="reset" id="addResult"/></div>
                        <input type="submit" class="btn btn-primary" value="导入"/>
                        <a href="#" class="btn btn-small" data-dismiss="modal">取消</a>
                    </div>
                </fieldset>
            </form>
        </div>
    </div>
</div>
</body>
</html>
